package com.kx.kxblog.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedBy;

import javax.persistence.*;
import java.util.Date;

@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@Accessors(chain = true)
@Table(indexes = @Index(columnList = "userId"))
@ApiModel(value = "Category", description = "分类")
public class Category extends AbstractEntity{
    @Column(nullable = false, unique = true, updatable = false)
    @ApiModelProperty(value = "用户id", required = true)
    @CreatedBy
    private Integer userId;

    @Column(length = 32)
    @ApiModelProperty(value = "名称")
    private String name;

    @Column
    @ApiModelProperty(value = "优先级")
    private Integer priority;

    @Column
    @ApiModelProperty(value = "修改时间")
    private Date modifyTime;

    @OneToOne
    @JoinColumn(name = "userId", insertable = false, updatable = false)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty(value = "用户", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    private User user;
}
